package com.shangwu.mapper;

import com.shangwu.pojo.Emp;
import org.apache.ibatis.annotations.*;
import org.springframework.cglib.core.Local;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    //    # 根据id删除员工
    @Delete(value = "delete from mybatis.emp where id = #{id}")
    public int delete(Integer id);
    //    # 新增员工
    @Options(keyProperty = "id",useGeneratedKeys = true)
    @Insert(value="insert into mybatis.emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time)" +
            "values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime});")
    public int insert(Emp emp);
    //    # 更新员工
    @Update(value = "update mybatis.emp " +
            "set username = #{username},name = #{name},gender = #{gender},image = #{image},job = #{job},entrydate = #{entrydate},dept_id = #{deptId},update_time = #{updateTime} where id = #{id};")
    public int update(Emp emp);
    //    # 根据id查询员工
    @Select(value="select * from mybatis.emp where id = #{id}")
    public Emp select01(Integer id);

    //    # 根据条件查询员工
    public List<Emp> select02(String name, Short gender, LocalDate begin,LocalDate end);


//    @Select(value="select * from mybatis.emp where name like concat('%',#{name},'%') " +
//            "and gender = #{gender} and entrydate between #{begin} and #{end} order by update_time desc;")
//    public List<Emp> select02(String name, Short gender, LocalDate begin,LocalDate end);


//    @Select(value="select * from mybatis.emp where name like '&{name}' " +
//            "and gender = #{gender} and entrydate between #{begin} and #{end} order by update_time desc;")
//    public List<Emp> select02(String name, Short gender, LocalDate begin,LocalDate end);

}
